package com.ldn.server.boot3.starter.config;

import com.ldn.server.boot3.starter.MyBatisFlexCollector;
import com.mybatisflex.core.FlexGlobalConfig;
import com.mybatisflex.core.audit.AuditManager;
import com.mybatisflex.core.mybatis.FlexConfiguration;
import com.mybatisflex.spring.boot.ConfigurationCustomizer;
import com.mybatisflex.spring.boot.MyBatisFlexCustomizer;
import com.mybatisflex.spring.boot.SqlSessionFactoryBeanCustomizer;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 李大牛家的牛 (scafel@163.com)
 * @product serverless
 * @className MyBatisFlexConfig
 * @createDate 2025/3/28 - 10:07
 * @description ToDo...
 **/
@Slf4j
@Configuration
public class MyBatisFlexConfig  implements
        ConfigurationCustomizer,
        SqlSessionFactoryBeanCustomizer,
        MyBatisFlexCustomizer
{


    public MyBatisFlexConfig() {
        AuditManager.setMessageCollector(new MyBatisFlexCollector());
        //开启审计功能
        AuditManager.setAuditEnable(true);
    }

    @Override
    public void customize(FlexConfiguration flexConfiguration) {
        log.info("customizing FlexConfiguration ex => {}", flexConfiguration);
    }

    @Override
    public void customize(FlexGlobalConfig flexGlobalConfig) {
        log.info("customizing FlexGlobalConfig {}", flexGlobalConfig);
    }

    @Override
    public void customize(SqlSessionFactoryBean sqlSessionFactoryBean) {
        log.info("customizing SqlSessionFactoryBean {}", sqlSessionFactoryBean);
    }
}